<template>
  <!-- 公告 -->
  <div class="box-card" v-skeleton.animated="loading">
    <h5 class="box-title">系统通知</h5>
    <ul class="box-card-list" v-if="noticeList.length > 0">
      <li v-for="(item, index) of noticeList" :key="index" v-skeleton-item>
        <p class="list-text">{{ item.text }}</p>
        <p class="list-time">{{ item.time }}</p>
      </li>
    </ul>
    <div class="box-empty" v-else>
      <img src="@common/assets/empty.svg" alt="" />
      <span>暂无预告</span>
    </div>
    <div class="box-page" v-if="noticeList.length > 0">
      <el-pagination
        v-model="pageData.currentPage"
        :page-size="5"
        :pager-count="4"
        :background="true"
        layout="total, prev, pager, next"
        :total="pageData.total"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent, reactive, toRefs } from 'vue'

export default defineComponent({
  name: 'newFeaturePreview',
  components: {},
  // ----------------生命周期-----------------------
  setup() {
    const state = reactive({
      noticeList: [
        // {
        //   text: '· 2022/05/04 更新说明',
        //   time: '10:00:00'
        // }
      ],
      pageData: {
        total: 100,
        currentPage: 1
      },
      loading: false
    })
    const handleCurrentChange = () => {
      console.log('handleCurrentChange')
    }
    const handleSizeChange = () => {
      console.log('handleSizeChange')
    }
    return {
      ...toRefs(state),
      handleCurrentChange,
      handleSizeChange
    }
  }
})
</script>

<style lang="stylus" scoped>
.box-card
  width 100%
  height 100%
  .box-title
    margin 0
    height: 22px;
    font-style: normal;
    font-weight: 500;
    font-size: 16px;
    line-height: 22px;
    letter-spacing: 0.001em;
    color: rgba(0, 0, 0, 0.88);
    flex: none;
    order: 0;
    flex-grow: 1;
    padding 20px 20px 16px
  .box-empty
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 0px;
    gap: 4px;
    height calc(100% - 74px)
    flex: none;
    order: 1;
    align-self: stretch;
    flex-grow: 1;
    font-style: normal;
    font-weight: 400;
    font-size: 14px;
    line-height: 20px;
  .box-card-list
    list-style none
    margin 0
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 0px 20px;
    width: 100%;
    // height calc(100% - 74px)
    flex: none;
    order: 0;
    flex-grow: 1;
    padding 16px 20px 0 20px
    box-sizing border-box
    li
      display: flex;
      flex-direction: row;
      align-items: center;
      padding: 0px;
      width: 100%;
      height: 36px;
      flex: none;
      align-self: stretch;
      flex-grow: 0;
      .list-text
        height: 20px;
        font-style: normal;
        font-weight: 400;
        font-size: 14px;
        line-height: 20px;
        display: flex;
        align-items: center;
        letter-spacing: 0.001em;
        color: rgba(0, 0, 0, 0.88);
        flex: 1;
        order: 0;
        flex-grow: 1;
      .list-text:hover
        color #409eff
        cursor pointer
      .list-time
        font-style: normal;
        font-weight: 400;
        font-size: 12px;
        line-height: 18px;
        display: flex;
        align-items: center;
        text-align: right;
        letter-spacing: 0.001em;
        color: rgba(0, 0, 0, 0.26);
        flex: none;
        order: 1;
        flex-grow: 0;
  .box-page
    display: flex;
    flex-direction: row;
    justify-content: flex-end;
    align-items: center;
    padding: 16px 20px 12px;
    gap: 8px;
    width: 100%;
    height: 52px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(8px);
    flex: none;
    order: 1;
    flex-grow: 0;
    box-sizing border-box
    .el-pagination
      padding 0
</style>
